package com.bytedance.improvingroad.banner_test

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bytedance.improvingroad.databinding.BannerImageTitleShowBinding
import com.youth.banner.adapter.BannerAdapter

/**
 * Created by chenxiong
 * date 12/7/21
 */
class ImageAdapter(datas: List<BannerModel>) : BannerAdapter<BannerModel, ImageAdapter.VH>(datas) {

    class VH(binding: BannerImageTitleShowBinding) : RecyclerView.ViewHolder(binding.root) {
         val imgView = binding.image
         val title = binding.title
        fun bind(data: BannerModel) {
            imgView.setImageResource(data.imgId)
            title.text = data.title
        }
    }

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): VH {
        return VH(BannerImageTitleShowBinding.inflate(LayoutInflater.from(parent?.context),parent,false))
    }

    override fun onBindView(holder: VH?, data: BannerModel?, position: Int, size: Int) {
            holder?.bind(getData(position))
    }

}